#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<bitset>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int n;
LL ans[N];
struct node
{
	int v;
	int id;
}S[N];
LL s1[N];
int cmp(node a, node b)
{
	return a.v < b.v;
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		LL temp = 0;
		int mi = 1e9;
		for (int i = 1; i <= n; i++) {
			int x;
			cin >> x;
			S[i] = { x,i };
			ans[i] = 0;
			s1[i] = 0;
			mi = min(mi, x);
		}
		sort(S + 1, S + n + 1, cmp);
		for (int i = 1; i <= n; i++) {
			s1[i] = s1[i - 1] + S[i].v;
			temp += (S[i].v - mi + 1);
		}
		for (int i = 1; i <= n; i++) {
			ans[S[i].id] = 1ll * i * (S[i].v + 1) - s1[i] + s1[n] - s1[i] - 1ll * (n - i) * (S[i].v - 1);
		}
		for (int i = 1; i <= n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	return 0;
}